package com.ax.service.imple;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;

import com.ax.pojo.TabTypes;
import com.ax.service.TabTypesService;
import com.ax.utils.BaseDaoSupport;

@Service("tabTypesService")
public class TabTypesServiceImple implements TabTypesService {

	private BaseDaoSupport<TabTypes> dao;
	@Resource(name="sessionFactory")
	public void setSessionFactort(SessionFactory sessionFactory){
		 dao=new BaseDaoSupport<TabTypes>();
		 dao.setSessionFactory(sessionFactory);
	}
	public List<TabTypes> findParentTypes() {
		List<TabTypes> b=dao.executeHQL("from TabTypes t left join fetch t.tabTypes where t.tabTypes is null", null);
		return b;
	}
	public TabTypes getParentTypes(String ParentID) {
		TabTypes b=(TabTypes)dao.getHibernateTemplate().get(TabTypes.class,Integer.parseInt(ParentID));
		return b;
	}
	public boolean saveTypes(TabTypes tabTypes) {
		boolean flag=true;
		try {
			dao.save(tabTypes);
		} catch (Exception e) {
			flag=false;
		}
		return flag;
	}
	public boolean updateType(TabTypes tabTypes) {
		boolean flag=true;
		try {
			dao.update(tabTypes);
		} catch (Exception e) {
			flag=false;
		}
		return flag;
	}
	public boolean delType(TabTypes tabTypes) {
		boolean flag=true;
		try {
			dao.delete(tabTypes);
		} catch (Exception e) {
			flag=false;
		}
		return flag;
	}

}
